package Demo_B;

public class Demo_B {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            System.out.println("子线程执行任务");
        }, "我的线程"); // 指定线程名称

        // 设置属性
        //设置线程优先级
        thread.setPriority(8);

        //设置线程为后台线程
        thread.setDaemon(true);

        // 启动线程
        thread.start();

        // 获取属性
        System.out.println("线程ID: " + thread.getId());
        System.out.println("线程名称: " + thread.getName());
        System.out.println("优先级: " + thread.getPriority());
        System.out.println("是否后台线程: " + thread.isDaemon());
        System.out.println("线程状态: " + thread.getState());
        System.out.println("是否存活: " + thread.isAlive());
    }
}